//
//  HOMeterViewController.m
//  微度报修
//
//  Created by foguo-mac-1 on 6/30/16.
//  Copyright © 2016 WeiDu. All rights reserved.
//

#import "HOMeterViewController.h"
#import "HOWaterMeterViewController.h"
#import "HOPeakValleyMeterViewController.h"
#import "HOMeterListViewController.h"
@interface HOMeterViewController ()

@end

@implementation HOMeterViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
	[self initTableView];
}

- (void)viewWillAppear:(BOOL)animated
{
	self.tabBarController.tabBar.hidden = YES;
	[super viewWillAppear:animated];
	[self setNavigationItemTitle:NSLocalizedString(@"抄表管理", @"抄表管理")];
	[self displayRightButtonItemWithTitle:NSLocalizedString(@"抄表列表", @"抄表列表")];
}


- (void)rightButtonItemDidClick
{
	HOMeterListViewController *viewCtrl = [[HOMeterListViewController alloc] init];
	[self.navigationController pushViewController:viewCtrl animated:YES];
	[viewCtrl release];
}
#pragma mark - -- UITableViewDelegate/UITableViewDataResource implement methods
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return CELL_HEIGHT;
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 4;
}


- (CGFloat) tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return SECTION_PADDING / 2;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *AMBaseTableViewCellIdentifier = @"UITableViewCell";
    UITableViewCell *cell = (UITableViewCell *)[tableView dequeueReusableCellWithIdentifier:AMBaseTableViewCellIdentifier];
    if(cell == nil)
    {
        cell = [[[UITableViewCell alloc]
                initWithStyle:UITableViewCellStyleDefault
                reuseIdentifier: AMBaseTableViewCellIdentifier] autorelease];
    }
	cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
	cell.textLabel.textColor = TEXT_COLOR_666666;
	cell.textLabel.font = [UIFont systemFontOfSize:15];
	if(indexPath.row == 0)
	{
		cell.textLabel.text = NSLocalizedString(@"水表", @"水表");
	}
	else if(indexPath.row == 1)
	{
		cell.textLabel.text = NSLocalizedString(@"峰谷电表", @"峰谷电表");
	}
	else if(indexPath.row == 2)
	{
		cell.textLabel.text = NSLocalizedString(@"气表", @"气表");
	}
	else if(indexPath.row == 3)
	{
		cell.textLabel.text = NSLocalizedString(@"电表", @"电表");
	}
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
	if(indexPath.row == 0)
	{
		HOWaterMeterViewController *viewCtrl = [[HOWaterMeterViewController alloc] init];
		viewCtrl.meterType = METER_TYPE_WATER;
		[self.navigationController pushViewController:viewCtrl animated:YES];
		[viewCtrl release];
	}
	else if(indexPath.row == 1)
	{
		HOPeakValleyMeterViewController *viewCtrl = [[HOPeakValleyMeterViewController alloc] init];
		[self.navigationController pushViewController:viewCtrl animated:YES];
		[viewCtrl release];
	}
	else if(indexPath.row == 2)
	{
		HOWaterMeterViewController *viewCtrl = [[HOWaterMeterViewController alloc] init];
		viewCtrl.meterType = METER_TYPE_GAS;
		[self.navigationController pushViewController:viewCtrl animated:YES];
		[viewCtrl release];
	}
	else if(indexPath.row == 3)
	{
		HOWaterMeterViewController *viewCtrl = [[HOWaterMeterViewController alloc] init];
		viewCtrl.meterType = METER_TYPE_ELECTRIC;
		[self.navigationController pushViewController:viewCtrl animated:YES];
		[viewCtrl release];
	}
    
}
#pragma mark - -- tool
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
